package com.ttfeed.server.common.domain.base;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageResult<T> {
    private List<T> content;
    private Long total;
    public Integer totalPage;
    private Integer pageNo = 1;
    private Integer pageSize = 15;

    public PageResult(Long total, Integer pageNo, Integer pageSize) {
        this.total = total;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.totalPage = (int) Math.ceil(total.doubleValue() / pageSize.doubleValue());
    }

    public static PageResult empty(){
        return new PageResult(0L,0,0);
    }
}
